import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

// 主题模式Provider
final themeModeProvider = StateProvider<ThemeMode>((ref) => ThemeMode.light);

// 用户设置Provider
class UserSettings {
  final String username;
  final bool notificationsEnabled;
  final String language;

  UserSettings({required this.username, required this.notificationsEnabled, required this.language});

  UserSettings copyWith({String? username, bool? notificationsEnabled, String? language}) {
    return UserSettings(
      username: username ?? this.username,
      notificationsEnabled: notificationsEnabled ?? this.notificationsEnabled,
      language: language ?? this.language,
    );
  }
}

// 用户设置Notifier
class UserSettingsNotifier extends StateNotifier<UserSettings> {
  UserSettingsNotifier() : super(UserSettings(username: 'Guest', notificationsEnabled: true, language: '中文'));

  void updateUsername(String username) {
    state = state.copyWith(username: username);
  }

  void toggleNotifications() {
    state = state.copyWith(notificationsEnabled: !state.notificationsEnabled);
  }

  void updateLanguage(String language) {
    state = state.copyWith(language: language);
  }
}

// 用户设置Provider
final userSettingsProvider = StateNotifierProvider<UserSettingsNotifier, UserSettings>((ref) {
  return UserSettingsNotifier();
});
